package com.qianfeng.teachdemo.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import com.android.volley.toolbox.NetworkImageView;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.qianfeng.teachdemo.R;
import com.qianfeng.teachdemo.bean.AppFreeBean;

import java.util.List;


/**
 * @version v1.0
 * @类描述：
 * @项目名称：StudyDemo
 * @包 名： com.qianfeng.studydemo.adapter
 * @类名称：CommonAdapter
 * @创建人：张唯
 * @创建时间：14-10-2
 * @修改人：
 * @修改时间：
 * @修改备注：
 */
public class CommonAdapter extends MeBaseAdapter<AppFreeBean> {
    public CommonAdapter(Context context, List<AppFreeBean> list) {
        super(context, list);
    }

    @Override
    public View createView(int i, View view, ViewGroup viewGroup) {
        AppFreeBean bean = list.get(i);
        ViewHolder vh = null;
        if (view == null) {
            view = inflater.inflate(R.layout.list_item_layout, viewGroup, false);
            vh = new ViewHolder();
            ViewUtils.inject(vh, view);
            view.setTag(vh);
        }else {
            vh = (ViewHolder)view.getTag();
        }
        vh.iv.setDefaultImageResId(R.drawable.ic_comment_weixin);
        vh.name.setText(bean.getName());
        vh.price.setText(new StringBuffer().append("价格: ").append(bean.getCurrentPrice()));
        vh.share.setText(new StringBuffer().append("分享: ").append(bean.getShares()));
        vh.collect.setText(new StringBuffer().append("收藏: ").append(bean.getFavorites()));
        vh.downCount.setText(new StringBuffer().append("下载量: ").append(bean.getDownloads()));
        return view;
    }

    private static class ViewHolder {
        @ViewInject(R.id.item_iv)
        private NetworkImageView iv;
        @ViewInject(R.id.item_name)
        private TextView name;
        @ViewInject(R.id.item_price)
        private TextView price;
        @ViewInject(R.id.item_share)
        private TextView share;
        @ViewInject(R.id.item_collect)
        private TextView collect;
        @ViewInject(R.id.item_downCount)
        private TextView downCount;


    }
}
